<?php

use Illuminate\Database\Seeder;

class AdminTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        //角色
        \Illuminate\Support\Facades\DB::table('system_role')->insert(
            [
            'name' => '超级管理员',
            'intro' => '超级管理员，最高权限',
            'auth' => '[]',
            'status' => 1,
            'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
            'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ]
        );

        //管理员
        \Illuminate\Support\Facades\DB::table('system_admin')->insert([
//            'role_id' => 1,
            'username' => 'admin',
            'password' => bcrypt('123456'),
            'nick'  => '超级管理员',
            'mobile' => '13800000001',
            'email' => 'admin@admin.com',
            'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
            'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
        ]);

        //管理员-角色
        \Illuminate\Support\Facades\DB::table('system_admin_role')->insert([
            'admin_id' => 1,
            'role_id' => 1,
            'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
        ]);

        //菜单
        \Illuminate\Support\Facades\DB::table('system_menu')->insert([
            [
                'pid' => 0,
                'module' => 'common',
                'url' => '/#',
                'title'  => '首页',
                'icon' => '',
                'sort' => 1,
                'system' => 1,
                'nav' => 1,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 1,
                'module' => 'common',
                'url' => '/my/index',
                'title'  => '个人资料',
                'icon' => '',
                'sort' => 1,
                'system' => 1,
                'nav' => 2,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 2,
                'module' => 'common',
                'url' => '/my/update',
                'title'  => '个人编辑',
                'icon' => '',
                'sort' => 1,
                'system' => 1,
                'nav' => 2,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 2,
                'module' => 'common',
                'url' => '/my/password',
                'title'  => '修改密码',
                'icon' => '',
                'sort' => 1,
                'system' => 1,
                'nav' => 2,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 1,
                'module' => 'common',
                'url' => '/my/#',
                'title'  => '快捷菜单',
                'icon' => 'aicon ai-shouye',
                'sort' => 1,
                'system' => 1,
                'nav' => 1,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 5,
                'module' => 'common',
                'url' => '/',
                'title'  => '首页信息',
                'icon' => 'aicon ai-shouyeshouye',
                'sort' => 1,
                'system' => 1,
                'nav' => 1,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],

            [
                'pid' => 0,
                'module' => 'system',
                'url' => '/system/#',
                'title'  => '系统',
                'icon' => '',
                'sort' => 99,
                'system' => 1,
                'nav' => 1,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 7,
                'module' => 'system',
                'url' => '/system/##',
                'title'  => '系统管理',
                'icon' => 'aicon ai-shezhi',
                'sort' => 1,
                'system' => 1,
                'nav' => 1,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 8,
                'module' => 'system',
                'url' => '/system/menu/index',
                'title'  => '菜单管理',
                'icon' => 'aicon ai-caidan',
                'sort' => 1,
                'system' => 1,
                'nav' => 1,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 9,
                'module' => 'system',
                'url' => '/system/menu/add',
                'title'  => '添加菜单',
                'icon' => '',
                'sort' => 1,
                'system' => 1,
                'nav' => 2,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 9,
                'module' => 'system',
                'url' => '/system/menu/update',
                'title'  => '编辑菜单',
                'icon' => '',
                'sort' => 1,
                'system' => 1,
                'nav' => 2,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 8,
                'module' => 'system',
                'url' => '/system/role/index',
                'title'  => '角色管理',
                'icon' => 'aicon ai-tubiao05',
                'sort' => 1,
                'system' => 1,
                'nav' => 1,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 12,
                'module' => 'system',
                'url' => '/system/role/add',
                'title'  => '添加角色',
                'icon' => '',
                'sort' => 1,
                'system' => 1,
                'nav' => 2,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 12,
                'module' => 'system',
                'url' => '/system/role/update',
                'title'  => '编辑角色',
                'icon' => '',
                'sort' => 1,
                'system' => 1,
                'nav' => 2,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 8,
                'module' => 'system',
                'url' => '/system/admin/index',
                'title'  => '管理员管理',
                'icon' => 'aicon ai-huiyuanliebiao',
                'sort' => 1,
                'system' => 1,
                'nav' => 1,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 15,
                'module' => 'system',
                'url' => '/system/admin/add',
                'title'  => '添加管理员',
                'icon' => '',
                'sort' => 1,
                'system' => 1,
                'nav' => 2,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],

            [
                'pid' => 15,
                'module' => 'system',
                'url' => '/system/admin/update',
                'title'  => '添加管理员',
                'icon' => '',
                'sort' => 1,
                'system' => 1,
                'nav' => 2,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 8,
                'module' => 'system',
                'url' => '/system/operate/index',
                'title'  => '操作日志',
                'icon' => 'aicon ai-xitongrizhi-tiaoshi',
                'sort' => 4,
                'system' => 2,
                'nav' => 1,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 8,
                'module' => 'system',
                'url' => '/system/config/index',
                'title'  => '系统配置',
                'icon' => 'fa fa-gear',
                'sort' => 1,
                'system' => 2,
                'nav' => 1,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 19,
                'module' => 'system',
                'url' => '/system/config/add',
                'title'  => '添加配置',
                'icon' => '',
                'sort' => 1,
                'system' => 2,
                'nav' => 1,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 19,
                'module' => 'system',
                'url' => '/system/config/update',
                'title'  => '编辑配置',
                'icon' => '',
                'sort' => 1,
                'system' => 2,
                'nav' => 1,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 12,
                'module' => 'system',
                'url' => '/system/role/menu',
                'title'  => '角色权限控制',
                'icon' => '',
                'sort' => 1,
                'system' => 2,
                'nav' => 1,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'pid' => 15,
                'module' => 'system',
                'url' => '/system/admin/password',
                'title'  => '管理员密码',
                'icon' => '',
                'sort' => 1,
                'system' => 1,
                'nav' => 2,
                'status' => 1,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
        ]);

        //添加100个菜单作为占位符，以便后期开发
        $menus = [];
        for ( $i=0; $i<100 ; $i++) {
            $menus[] = [
                'pid' => 0,
                'module' => 'system',
                'url' => rand(10000,99999),
                'title'  => '占位符',
                'icon' => '',
                'sort' => 1,
                'system' => 1,
                'nav' => 2,
                'status' => 2,
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ];
        }

        \Illuminate\Support\Facades\DB::table('system_menu')->insert($menus);

        //插入配置文件
        $systemConfigs = [
            [
                'name'=>'backstage_title',
                'title' => '后台标题',
                'group' => 'system',
                'type' => 1,
                'status' => 1,
                'value' => '个人后台',
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],
            [
                'name'=>'logo',
                'title' => 'logo图',
                'group' => 'system',
                'type' => 4,
                'status' => 1,
                'value' => '',
                'created_at' => \Carbon\Carbon::now()->toDateTimeString(),
                'updated_at' => \Carbon\Carbon::now()->toDateTimeString(),
            ],

        ];

        \Illuminate\Support\Facades\DB::table('system_config')->insert($systemConfigs);


    }
}
